import request from "@/axios/request";
import url from "@/axios/url";
const { mesUrl, adminUrl, qmsUrl, baseDataUrl } = url();
// 导出url
export const exportUrl = `${mesUrl}mesProdOrderPlan/export`;
// 分页查询
export function getList (params = {}) {
  return request({
    url: `${mesUrl}mesProdOrderPlan/selectList`,
    method: "get",
    params,
  });
}
// 新增
export function rowCreate (data = {}) {
  return request({
    url: `${mesUrl}mesProdOrderPlan`,
    method: "post",
    data,
  });
}
// 修改
export function rowUpdate (data = {}) {
  return request({
    url: `${mesUrl}mesProdOrderPlan`,
    method: "put",
    data,
  });
}
// 删除
export function rowDel (id) {
  return request({
    url: `${mesUrl}mesProdOrderPlan/${id}`,
    method: "put",
  });
}
// 详情
export function rowDetail (id) {
  return request({
    url: `${mesUrl}mesProdOrderPlan/info/${id}`,
    method: "get",
  });
}

// 导入用户
export function importData (data = {}) {
  return request({
    url: `${mesUrl}mesProdOrderPlan/import`,
    method: "POST",
    data,
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });
}
// 下载模板
export const downloadTemplateUrl = `${mesUrl}mesProdOrderPlan/template`;

// 查询订单状态列表
export function getOrderStatusList () {
  return request({
    url: `${adminUrl}dict/type/plan_status`,
    method: "get",
  });
}
// 查询虚实订单类型（无bom虚单，实单，bom需单）列表
export function getSimulatedTypeList () {
  return request({
    url: `${adminUrl}dict/type/simulated_type`,
    method: "get",
  });
}
export function getSalesOrderList (params = {}) {
  return request({
    url: `${mesUrl}mesSalesOrder`,
    method: "get",
    params,
  });
}
export function salesDetail (params) {
  return request({
    url: `${mesUrl}mesSalesOrderDetail/list`,
    method: "get",
    params,
  });
}

export function getDeliveryMethodList () {
  return request({
    url: `${adminUrl}dict/type/shipping_method`,
    method: "get",
  });
}
export function getListByPlanCode (id) {
  return request({
    url: `${mesUrl}mesProdOrder/getListByPlanCode/${id}`,
    method: "get",
  });
}
export function getMaterialListByPlanCode (id) {
  return request({
    url: `${mesUrl}mesRequisitionOrderScan/getMaterialListByPlanCode/${id}`,
    method: "get",
  });
}
export function getWholeProcess (id) {
  return request({
    url: `${mesUrl}mesProdOrderPlan/getWholeProcess/${id}`,
    method: "get",
  });
}
export function getWholeProcessOrder (id) {
  return request({
    url: `${mesUrl}mesProdOrder/getWholeProcess/${id}`,
    method: "get",
  });
}
//生产信息
export function getProductionProcess (data) {
  return request({
    url: `${mesUrl}orderTracking/getProductionProcess`,
    method: "post",
    data,
  });
}
//查询过程质检列表
export function getMesCheckRecordList (id) {
  return request({
    url: `${mesUrl}orderTracking/getMesCheckRecordList/${id}`,
    method: "get",
  });
}
//查询绑料记录
export function getMesScanKeyPartsList (data) {
  return request({
    url: `${mesUrl}orderTracking/getMesScanKeyPartsList`,
    method: "post",
    data,
  });
}
//日志
export function getProductionLog (id) {
  return request({
    url: `${mesUrl}mesScanRecordDetail/getProductionLog/${id}`,
    method: "get",
  });
}
// 查询生产订单类型：内销，外销，样机列表
export function getProdOrderTypeList () {
  return request({
    url: `${adminUrl}dict/type/prod_order_type`,
    method: "get",
  });
}
//查询绑料记录
export function getMessageByOrderCode (data) {
  return request({
    url: `${mesUrl}mesScanRecordDefective/selectByOrderCode`,
    method: "get",
    data,
  });
}
//根据生产工单查询异常信息
export function selectByOrderCode (orderCode) {
  return request({
    url: `${mesUrl}mesScanRecordDefective/selectByOrderCode/${orderCode}`,
    method: "get",
    // data,
  });
}
//根据生产工单查询检验结果
export function qmsInspectionResult (params) {
  return request({
    // url: `${mesUrl}mes-biz/mesScanRecordDefective/selectByOrderCode/${data['orderCode']}`,
    url: `${qmsUrl}qmsInspectionResult/selectByTemplateType`,
    method: "GET",
    params
  });
}
//查询异常物料接口
export function mesMaterialRequisitionDetail (data) {
  return request({
    url: `${mesUrl}mesMaterialRequisitionDetail/list`,
    method: "get",
    params: data,
  });
}
//根据生产工单查询上料验证
export function mesMaterialRequisition (data) {
  return request({
    url: `${mesUrl}mesMaterialRequisition/list`,
    method: "get",
    params: data,
  });
}
//排期保存
export function subBatchOrder (data) {
  return request({
    url: `${mesUrl}mesProdOrder/batchOrder`,
    method: "post",
    data,
  });
}

//开工验证信息
export function mesScanStart (data) {
  return request({
    url: `${mesUrl}mesScanStart/list`,
    method: "get",
    params: data,
  });
}

//上料验证信息
export function mesLoadmaterialVerificationDetail (data) {
  return request({
    url: `${mesUrl}mesLoadMaterialVerificationDetail/list`,
    method: "get",
    params: data,
  });
}

// 查询线体编码列表
export function getLineCodeListNew (params) {
  return request({
    url: `${adminUrl}baseFactoryModeling/children`,
    method: "get",
    params,
  });
}
// 查询工位编码列表
export function getWorkCellCodeList (params) {
  return request({
    url: `${adminUrl}baseFactoryModeling/children`,
    method: "get",
    params,
  });
}
// 根据生产订单号获取生成工单列表
export function getMesProdOrderListByPlanCode (params) {
  return request({
    url: `${mesUrl}mesProdOrder/getMesProdOrderListByPlanCode`,
    method: "get",
    params,
  });
}
// 多次排期保存
export function batchGenerateOrder (data) {
  return request({
    url: `${mesUrl}mesProdOrder/batchGenerateOrder`,
    method: "post",
    data
  });
}
